/**
*┌──────────────────────────────────────────────────────────────┐
*│　描    述：SysButton仓储                                              
*│　作    者：sys                                            
*│　创建时间：2020-12-02 14:55:26  
*│　说    明：代码生成器生成   
*└──────────────────────────────────────────────────────────────┘
*/
using SXFramWork.Core;
using SXFramWork.Model;
using System;
using System.Threading.Tasks;

namespace SXFramWork.Repository
{
    public class SysButtonRepository:RepositoryAbstract<SysButtonEntity>,ISysButtonRepository
    {
        public SysButtonRepository(IDbContext dbContext):base(dbContext)
        {
          
        }

        public async Task<string> GetBtnAsync(string userId)
        {
            var sql = @"  select stuff((  select ','+  sb.Code from SysButton sb left join SysPermission sp on sb.PermissionCode=sp.Code 
            left join SysRolePermission srp on srp.PermissionId=sp.Id left join SysUserRole sur on sur.SysRoleId=srp.RoleId where sur.SysUserId=@UserId for xml path('')),1,1,'')";
            return await FromSql.GetStrAsync(sql, new { UserId = userId });
        }
    }
}